@use "../_variables" as *;

.tools-page {
  width: 100%;
  max-width: $chat-width;
  min-width: min-content;
  margin: 0 auto;

  .header-actions {
    display: flex;
    gap: 12px;

    .oap-logo {
      height: 22px;
      width: 22px;
    }
  }

  .tools-container {
    width: 100%;
    flex-direction: column;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
  }
}

.tools-list {
  width: 100%;
  flex: 1;

  .tools-type-tabs {
    margin-bottom: 23px;
    margin-left: auto;

    .tabs-item {
      padding: 8px 12px;
    }
  }

  .tool-section {
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-gray-weak);
    box-shadow: 0 2px 6px var(--sd);

    .tool-header-container {
      padding: 16px;
      cursor: pointer;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: center;

      .tool-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;

        .tool-header-content {
          display: flex;
          flex: 1;
          align-items: center;
          gap: 12px;

          img, svg {
            width: 24px;
            height: 24px;
          }

          svg {
            fill: var(--text-weak);
          }

          .tool-header-content-icon {
            color: var(--text-weak);
          }

          .oap-logo {
            opacity: 1;
          }

          .tool-name {
            font-weight: 500;
          }

          .tool-tag {
            font-size: 13px;
            font-weight: 400;
            color: var(--text-weak);
            background: var(--bg-gray-medium);
            padding: 3px 8px;
            border-radius: 200px;
            white-space: nowrap;

            &.PRO {
              background-color: var(--bg-pri-weak);
              border: none;
            }
          }

          .tool-status-light {
            display: flex;
            align-items: center;
            width: 16px;
            height: 16px;

            svg {
              opacity: 1;
              width: 16px;
              height: 16px;
            }

            .tool-status-light-icon {
              &.success {
                color: var(--stroke-success);
              }

              &.danger {
                color: var(--stroke-danger);
              }

              &.warning {
                color: var(--stroke-warning);
              }
            }

            .loading-spinner {
              @include loading-spinner(16px, 4px, var(--bg-pri-strong), var(--bg-gray-medium));
            }
          }

          .oap-store-link {
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: none;
            color: var(--text-strong);
            padding: 2px;
            border-radius: 50%;

            svg {
              width: 22px;
              height: 22px;
              opacity: 1;
            }

            &:hover {
              background-color: var(--bg-gray-medium);
              color: var(--text-strong);
            }

            &:focus {
              outline: none;
            }
          }
        }

        .tool-disabled-label {
          color: var(--text-weak);
          font-size: 14px;
          margin-left: 12px;
          display: flex;
          align-items: center;
          white-space: nowrap;
        }

        .tool-toggle {
          width: 18px;
          font-size: 18px;
          transition: transform 0.3s;
          display: flex;
          align-items: center;
          justify-content: center;
        }

        .tool-edit-menu {
          width: 42px;
          height: 42px;
          padding: 2px;
          border-radius: 50%;
          cursor: pointer;
          display: flex;
          align-items: center;
          justify-content: center;
          opacity: 0;
          transition: opacity $transition-fast ease-in-out;

          &:hover,
          &[data-state="open"] {
            opacity: 1;
            background: var(--bg-gray-medium);
          }
        }
      }

      &:has(.tool-edit-menu:hover),
      &:has(.oap-store-link:hover),
      &:has(.custom-button:hover) {
        background: transparent;
      }

      &:hover {
        background: var(--bg-gray-medium);

        .tool-header {
          .tool-edit-menu {
            opacity: 1;
          }
        }
      }

      .tool-content-sub-title {
        padding-left: 64px;
        font-size: 13px;
        font-weight: 500;
        color: var(--text-weak);
        margin-top: -9px;
        width: 100%;
        display: flex;
        flex-direction: column;

        &.danger {
          color: var(--text-danger);
        }

        &.warning {
          color: var(--text-warning);
        }
      }
    }

    .tool-content-container {
      display: none;

      .tool-content {
        display: block;
        padding: 0;
        max-height: 420px;
        overflow-y: auto;
        border-top: 1px solid;
        border-color: var(--stroke-gray-medium);

        @include scrollbar;

        .tool-description {
          margin-bottom: 16px;
          color: var(--text-weak);

          @include line-clamp(3);
        }

        &:has(.sub-tool-error) {
          padding: 15px;
        }

        .sub-tool-error {
          color: var(--text-danger);
          display: flex;
          align-items: flex-start;
          gap: 12px;
          padding: 12px;
          border-radius: 6px;
          background: var(--bg-danger-weak);
          max-height: 125px;
          overflow-y: auto;
          box-shadow: 0 1px 3px var(--sd);

          @include scrollbar;

          svg {
            width: 18px;
            height: 18px;
          }

          .sub-tool-error-text {
            flex: 1;
            font-size: 14px;

            .sub-tool-error-text-title {
              font-weight: 700;
              margin-bottom: 4px;
            }

            .sub-tool-error-text-content {
              color: var(--text-weak);
            }
          }
        }
      }
    }

    .sub-tools {
      display: flex;
      flex-wrap: wrap;
      padding: 10px 16px;
      gap: 12px;

      .sub-tool-name {
        font-weight: 600;
        font-size: 15px;
      }
    }

    &.loading {
      cursor: not-allowed;
      .sub-tools {
        button {
          pointer-events: none;
        }
      }
    }

    .sub-tools-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 12px;
      border-top: 1px solid var(--stroke-gray-medium);
    }

    &.expanded {
      .tool-toggle {
        transform: rotate(180deg);
      }

      .tool-content-container {
        display: block;
      }
    }

    &.disabled {
      &.enabled {
        .tool-disabled-label {
          color: var(--text-danger);
        }
      }
    }
  }
}

.tool-switch-container {
  margin: 0 12px;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.sub-tool {
  display: flex;
  justify-content: space-between;
  align-items: center;

  .sub-tool-content {
    flex: 1;
  }
}

.tools-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 55px;
  position: relative;
  width: 100%;
  font-size: 20px;
  font-weight: 600;

  .header-actions {
    display: flex;
    gap: 12px;
  }
}

.tool-edit-popup-container {
  .popup-confirm-content {
    flex-shrink: 0;
  }

  .tool-edit-popup-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 10px 16px;
    font-size: 20px;
    font-weight: 700;
    width: 100%;
    gap: 8px;
  }

  .tool-edit-popup {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: 0;

    .tool-edit-list {
      width: 250px;
      height: calc( 100% + 73px );
      z-index: 1;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 10px;
      padding: 20px;
      background: var(--bg-gray-weak);
      overflow-x: hidden;

      @include scrollbar;

      .tool-edit-list-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-radius: 4px;
        padding: 8px 10px;
        background: var(--bg-gray-medium);
        box-shadow: 0 2px 6px var(--sd);
        color: var(--text-strong);
        cursor: pointer;
        transition: all 0.2s;

        &.active {
          background: var(--bg);
          border-radius: 4px 0 0 4px;
          width: calc(100% + 20px);
        }

        &:hover {
          background: var(--bg-pri-ultraweak);
        }

        &.error {
          color: var(--text-danger);
          border: 1px solid var(--stroke-danger);
        }

        .tool-edit-list-item-content {
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 4px;
          cursor: pointer;
          width: 100%;
          max-width: 190px;

          .left {
            display: flex;
            align-items: center;
            gap: 4px;
          }

          .right {
            display: flex;
            align-items: center;
            gap: 4px;
          }

          .tool-edit-list-item-connect-icon {
            &.connected {
              color: var(--stroke-success);
            }

            &.unconnected {
              color: var(--stroke-danger);
            }
          }
        }

        label {
          flex: 1 1 0;
          cursor: pointer;
          @include line-clamp(1);
        }
      }
    }

    .tool-edit-popup-content {
      display: flex;
      flex-direction: column;
      flex: 1;
      padding: 20px;
      overflow-y: auto;

      @include scrollbar;
    }

    .tool-edit-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 0;
      font-size: 20px;
      font-weight: 700;
      gap: 10px;

      .tool-edit-header-title {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 5px;
        word-break: break-word;
      }

      .tool-edit-header-actions {
        display: flex;
        align-items: center;
        gap: 10px;
      }
    }

    .tool-edit-content {
      display: flex;
      flex: 1;
      gap: 20px;
      overflow: hidden;

      .tool-edit-title {
        font-size: 18px;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 5px;

        .tool-edit-desc {
          font-size: 12px;
          font-weight: 400;
          color: var(--text-weak);
        }
      }

      .tool-edit-field {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        min-height: 0;

        @include scrollbar;

        .tool-edit-field-desc {
          font-size: 14px;
          font-weight: 400;
          padding: 16px 5px;
        }

        .select-button {
          width: 100%;
          height: 30px;
          border: none;
          border-radius: 10px;
          text-align: start;
          padding: 0 10px;
          background: var(--bg-gray-medium);
          color: var(--text-strong);
          font-size: 15px;

          &[type="number"] {
            -moz-appearance: textfield;
            appearance: textfield;
            grid-column: span 2;
          }

          &[type="number"]::-webkit-outer-spin-button,
          &[type="number"]::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
          }
        }

        .field-content {
          display: flex;
          flex-direction: column;
          gap: 12px;
          width: 100%;
          padding: 0 5px;
          white-space: nowrap;

          .field-item {
            display: flex;
            flex-direction: column;
            gap: 4px;

            .field-item-title {
              display: flex;
              align-items: center;
              gap: 4px;
            }

            .field-item-array {
              display: flex;
              flex-direction: column;
              gap: 4px;
            }

            label {
              display: flex;
              justify-content: space-between;
              align-items: center;
              font-size: 15px;
              font-weight: 700;

              button {
                background: none;
                border: none;
                color: var(--text-weak);
                cursor: pointer;
                font-size: 14px;
                font-weight: 500;
                padding: 0;
                transition: all 0.2s;

                &:hover {
                  color: var(--text-medium);
                }

                &:focus {
                  outline: none;
                }
              }
            }

            .select-button {
              &:focus {
                outline: none;
              }
            }

            &.error {
              .select-button {
                border: 2px solid var(--stroke-danger);
              }
            }
          }

          .key-input-wrapper {
            position: relative;

            .key-input-error {
              position: absolute;
              top: 0;
              left: 0;
              width: 100%;
              height: 100%;
              cursor: text;
            }
          }

          .field-item-array {
            border-top: 1px solid var(--stroke-gray-medium);

            &.no-border {
              border-top: none;
            }

            .field-item-array-item {
              display: flex;
              justify-content: space-between;
              align-items: center;
              gap: 5px;

              .field-item-array-item-clear {
                width: 20px;
                height: 20px;
                cursor: pointer;
                background: var(--bg-gray-medium);
                border-radius: 50%;
                padding: 2px;
                flex-shrink: 0;

                &:hover {
                  background: var(--bg-gray-strong);
                }

              }
            }

          }
        }
      }

      .tool-edit-json-editor {
        display: flex;
        flex-direction: column;
        flex: 1;
        width: 500px;
        position: relative;
        overflow-y: auto;
        min-height: 0;

        @include scrollbar;

        &.edit-json,
        &.add-json {
          min-width: 820px;
        }

        > [class^="cm-theme-"] {
          display: flex;
          flex: 1;
          min-height: 0;

          .cm-editor {
            flex: 1;

            &.cm-focused {
              outline: none;
            }

            .cm-scroller {
              @include scrollbar;
            }
          }
        }

        .tool-edit-json-editor-copy {
          position: absolute;
          bottom: 0;
          right: 0;
          display: flex;
          align-items: center;
          gap: 10px;
          color: var(--text-weak);

          div {
            cursor: pointer;
            transition: all 0.2s;

            &:hover {
              color: var(--text-medium);
            }
          }
        }

        &.submitting {
          .cm-editor {
            margin-bottom: -10px;
          }

          .tool-edit-json-editor-copy {
            bottom: 160px;
          }
        }

        .tool-edit-json-editor-log {
          height: 260px;
          border-radius: 12px 12px 0 0;
          box-shadow: 0 5px 5px var(--sd);
          overflow: hidden;
          display: flex;
          flex-direction: column;
          z-index: 1;

          .tool-edit-json-editor-log-title {
            display: flex;
            align-items: center;
            gap: 15px;
            padding: 9.5px 30px;
            background-color: var(--bg);
            font-weight: 500;
            font-size: 12px;
          }

          .tool-edit-json-editor-log-title-icon {
            display: flex;
            align-items: center;
            color: var(--text-pri);
            font-size: 13px;
          }

          @keyframes rotate {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
          }

          .tool-edit-json-editor-log-title-icon svg {
            margin-right: 5px;
            animation: rotate 1.5s infinite;
          }

          .tool-edit-json-editor-log-content {
            padding: 12px 16px;
            max-height: 500px;
            overflow-y: auto;
            overflow-x: auto;
            font-size: 13px;
            line-height: 1.6;
            background-color: var(--bg-gray-strong);
            color: var(--text-invert);
            flex: 1;
            display: grid;
            grid-template-columns: max-content;
            align-content: start;

            @include scrollbar-light;
          }

          .log-entry {
            display: block;
            min-width: calc(100% + 32px);
            padding: 4px 0;
            margin-left: -16px;
            margin-right: -16px;
            padding-left: 16px;
            padding-right: 16px;
            border-bottom: 1px solid var(--stroke-gray-medium);
            white-space: nowrap;
            box-sizing: border-box;
          }

          .timestamp {
            color: var(--text-medium);
            margin-right: 10px;
          }

          .debug-label {
            color: var(--text-pri);
            font-weight: 500;
            margin-right: 10px;
          }

          .log-mcp-server-name {
            color: var(--text-invert);
            margin-right: 10px;
          }

          .log-content {
            color: var(--text-invert);
          }

          .log-dots {
            width: 20px;
            height: 30px;
            display: inline-block;
            position: relative;
            overflow: hidden;
          }

          .log-dots::after {
            content: "...";
            position: absolute;
            left: 0;
            animation: horizontalDots 1.5s infinite steps(4, end);
            letter-spacing: 2px;
            color: var(--text-pri);
            font-size: 20px;
            font-weight: 900;
          }

          @keyframes horizontalDots {
            0% { clip-path: inset(0 100% 0 0); }
            25% { clip-path: inset(0 75% 0 0); }
            50% { clip-path: inset(0 50% 0 0); }
            75% { clip-path: inset(0 25% 0 0); }
            100% { clip-path: inset(0 0 0 0); }
          }
        }
      }
    }
  }

  &.connector-popup-container {
    .tool-edit-popup {
      width: 100%;

      .tool-edit-popup-content {
        .tool-edit-field {
          width: 100%;
        }

        .oauth-alert {
          display: flex;
          gap: 30px;
          background-color: var(--bg-gray-medium);
          padding: 15px 17px;
          font-size: 14px;
          border-radius: 4px;
          white-space: normal;

          svg {
            flex: 0 0 auto;
          }
        }
      }
    }
  }

  .tool-edit-popup-footer-hint {
    margin-left: 250px;
    display: flex;
    gap: 10px;
  }
}

.loading-spinner {
  @include loading-spinner(72px, 8px, var(--stroke-pri-strong), var(--bg-gray-medium));
}

.tool-edit-menu-item {
  display: flex;
  gap: 10px;

  svg {
    color: var(--text-weak);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.global-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-gray-op-medium);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2501;
  pointer-events: auto;

  .loading-spinner {
    @include loading-spinner(40px, 8px, var(--stroke-pri-strong), var(--bg-gray-medium));
  }
}

.tool-confirm-content {
  display: flex;
  flex-direction: column;
  padding-left: 50px;
  padding-right: 50px;
  color: var(--text-weak);
}

.connector-loading-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 15px;
}

.oap-popup {
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: $header-height;

  .popup-confirm-content {
    flex: 1 1 0;
  }

  .oap-container {
    overflow: hidden;
    flex: 1;
    width: 100%;
    flex-direction: column;
    display: flex;
    gap: 10px;
  }

  .oap-header {
    padding: 0 16px;
    display: flex;
    align-items: center;

    .oap-title {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 24px;
      font-weight: 600;
      margin-right: 24px;
      white-space: nowrap;

      .oap-logo {
        width: 24px;
        height: 24px;
      }
    }
  }

  .oap-search-wrapper {
    display: flex;
    flex: 1;
    align-items: center;
  }

  .oap-search-container {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 5px;
    padding: 7px;
    padding-right: 0;
    border: 1px solid var(--stroke-gray-medium);
    background-color: var(--bg-gray-weak);
    height: 36px;
    max-width: 500px;
    border-radius: 8px;

    .oap-search-input {
      border: none;
      height: 100%;
      width: 100%;
      flex: 1;
      background: transparent;
      color: var(--text-strong);

      &:focus {
        outline: none;
      }
    }

    .oap-search-clear {
      width: 20px;
      height: 20px;
      cursor: pointer;
      background: var(--bg-gray-medium);
      border-radius: 50%;
      padding: 2px;

      &:hover {
        background: var(--bg-gray-strong);
      }
    }

    .oap-subscription {
      display: flex;
      align-items: center;
      font-size: 14px;
      background-color: var(--bg-gray-medium);
      padding: 4px 10px;
      height: 36px;
      white-space: nowrap;
      border-radius: 11px 8px 8px 11px;
      border: none;

      &:focus {
        outline: none;
      }
    }
  }

  .oap-filter {
    display: flex;
    padding: 12px 16px;
    overflow: hidden;
    gap: 24px;
    white-space: nowrap;
  }

  .oap-filter-label {
    font-size: 14px;
    color: var(--text-weak);
  }

  .oap-sorts {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .oap-filter-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 100%;
    width: 0;
  }

  .oap-filter-tags-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 100%;
    width: 0;

    @include scrollbar;
  }

  .oap-filter-tag {
    padding: 3px 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    background-color: var(--bg-gray-medium);
    border-radius: 20px;
    transition: all 0.2s ease;

    &:hover {
      background-color: var(--bg-gray-strong);
    }
  }

  .oap-filter-tag.active {
    color: var(--text-invert);
    background-color: var(--bg-pri-medium);
    font-weight: 600;

    &:hover {
      background-color: var(--bg-pri-strong);
    }
  }

  .oap-item-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;

    > .default-loader {
      margin: auto;

      svg {
        color: var(--text-pri);
      }
    }
  }

  .oap-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: min-content;
    gap: 12px;
    padding: 8px;
    overflow-y: auto;
    @include scrollbar;

    .default-loader svg {
      color: var(--text-pri);
    }

    @media (max-width: $breakpoint-xl) {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  .oap-item {
    display: flex;
    gap: 12px;
    border-radius: 12px;
    align-items: flex-start;
    cursor: pointer;
    height: auto;
    position: relative;
    box-shadow: 0px 3px 7px 0px var(--sd);

    &:not(.disabled):hover {
      outline: 3px solid var(--stroke-pri-strong);

      .oap-item-container {
        .oap-item-img {
          .oap-checkbox {
            display: flex;
          }
        }
      }
    }

    &.disabled {
      cursor: not-allowed;

      .oap-item-container {
        .oap-item-img {
          .oap-checkbox {
            display: none;
          }
        }

        .oap-item-content {
          opacity: 0.5;
        }
      }
    }

    &:has(.oap-checkbox input:checked) {
      outline: 3px solid var(--stroke-pri-strong);
    }

    .oap-item-container {
      display: flex;
      flex-direction: column;
      height: 100%;
      width: 100%;
      border-radius: 12px;
      overflow: hidden;

      .oap-item-img {
        width: 100%;
        height: 100px;
        position: relative;

        img {
          width: 100%;
          height: 100%;
          object-fit: cover;
        }

        .oap-item-icon-wrapper {
          display: flex;
          align-items: center;
          justify-content: start;
          gap: 10px;
          width: 100%;
          height: 100%;
          background-color: var(--bg-gray-medium);
          border-radius: 12px 12px 0 0;
          padding: 0 40px;

          .oap-item-icon {
            width: 52px;
            height: 52px;
            padding: 5px;
            border-radius: 12px;
            background-color: var(--bg-light);
          }

          .oap-item-icon-text {
            font-size: 25px;
            font-weight: 700;
            color: var(--text-strong);
          }
        }

        .oap-tags {
          position: absolute;
          bottom: 0;
          right: 0;
          margin: 0 7px 7px 0;
          display: flex;

          .oap-tag {
            color: var(--text-invert);
            font-weight: 700;

            &.popular {
              background-color: var(--bg-pri-medium);
            }

            &.new {
              background-color: var(--bg-danger-medium);
            }
          }
        }

        .oap-checkbox {
          z-index: 2;
          display: flex;
          align-items: center;
          justify-content: center;
          position: absolute;
          left: 15px;
          top: 15px;
          background-color: var(--bg);
          border-radius: 4px;
          display: none;

          &:has(input:checked) {
            display: flex;
          }
        }
      }

      .oap-item-content {
        display: flex;
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        gap: 4px;
        padding: 6px 14px;
        position: relative;

        .oap-item-content-top,
        .oap-item-content-bottom {
          display: flex;
          flex-direction: column;
          align-items: flex-start;
          gap: 4px;
          width: 100%;
        }
      }
    }
  }

  .oap-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;

    .oap-content-title {
      display: flex;
      align-items: center;
      gap: 10px;

      .oap-title-text {
        font-size: 18px;
        font-weight: 700;
        color: var(--text-strong);

        @include line-clamp(1);
      }

      .oap-title-text-hightlight {
        color: var(--text-pri);
      }

      .oap-content-title-hint {
        display: flex;
        align-items: center;
        color: var(--text-weak);
        cursor: default;
      }
    }

    .oap-cost {
      display: flex;
      align-items: center;
      gap: 5px;
      font-size: 15px;
      font-weight: 700;

      &:hover {
        text-decoration: underline;
      }

      .oap-cost-icon {
        width: 16px;
        height: 16px;
        color: var(--text-medium);
      }
    }
  }

  .oap-metadata-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 6px;
    gap: 12px;
    width: 100%;

    .oap-metadata {
      display: flex;
      font-size: 12px;
      color: var(--text-weak);
      gap: 12px;
      align-items: center;
    }

    .oap-store-link {
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      background: none;
      padding: 0;
      color: var(--text-medium);
      padding: 4px;
      border-radius: 50%;

      &:hover {
        background-color: var(--bg-gray-medium);
        color: var(--text-strong);
      }

      &:focus {
        outline: none;
      }
    }
  }

  .oap-description {
    font-size: 13px;
    color: var(--text-weak);

    @include line-clamp(2);
  }

  .oap-tags {
    display: flex;
    align-items: center;
    gap: 4px;

    .oap-tag {
      border: 1px solid var(--stroke-gray-medium);
      color: var(--text-strong);
      padding: 2px 8px;
      border-radius: 20px;
      font-size: 12px;
      height: 24px;
      line-height: 20px;
      text-transform: capitalize;

      &.BASE {
        color: var(--text-strong);
        background-color: var(--bg-gray-strong);
      }

      &.PRO {
        color: var(--text-invert);
        background-color: var(--bg-pri-medium);
      }
    }
  }

  .oap-loading {
    text-align: center;
    padding: 20px;
    color: #666;
    grid-column: span 2;
  }

  .oap-footer-hint {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: default;
    color: var(--text-weak);
    font-weight: 500;
    font-size: 14px;
  }
}

.no-oap-result-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
  margin: auto;
  padding: 2.5rem;
  text-align: center;
  animation: fadeIn 0.5s ease-out;

  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  .cloud-icon {
    width: 48px;
    height: 48px;
    position: relative;
    color: var(--stroke-pri-strong);
    opacity: 0.5;
  }

  .no-oap-result-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-strong);
  }

  .no-oap-result-message {
    font-size: 15px;
    color: var(--text-weak);
    margin-bottom: 12px;
  }
}

.oap-content-title-tooltip {
  flex-direction: column;
  align-items: flex-start;
  width: min(530px, var(--radix-tooltip-content-available-width));
  max-height: min(540px, var(--radix-tooltip-content-available-height));
  overflow-y: auto;
  user-select: text;

  @include scrollbar;

  h1, h2, h3, h4, h5, h6 {
    color: var(--text-strong);
    margin: 10px;
  }

  strong {
    margin: 0;
  }

  p, blockquote, ul, ol, details, pre {
    margin: 0 0 10px 10px;
  }

  ul {
    padding-top: 5px;
  }

  li {
    line-height: 1.5;
  }

  h1 {
    width: 100%;
    font-size: 1.8em;
    margin: 15px 0 10px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--stroke-gray-medium);
  }

  h1, ul {
    line-height: 1;
  }

  pre:has(.code-block) {
    width: 100%;
    border: 1px solid var(--stroke-gray-medium);
    border-radius: 3px;
    margin: 0;
    margin-bottom: 10px;
  }

  .code-block {
    position: relative;

    pre {
      @include scrollbar;
    }
    code {
      background: none!important;

      span {
        border: none;
        padding: 0;
        font-size: 13px;
      }
    }

    .copy-btn {
      position: absolute;
      bottom: 5px;
      right: 10px;
      background: none;
      border: none;
      cursor: pointer;
      padding: 0;
      color: var(--text-weak);

      &:focus {
        outline: none;
      }

      &:hover {
        color: var(--text-strong);
      }
    }
  }

  .oap-content-title-link {
    color: var(--text-pri);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    border: none;
    font-size: 16px;
  }

  table {
    table-layout: auto;
    width: 100%;
    border-spacing: 0;
    border-collapse: collapse;
    margin-bottom: 10px;

    th, td {
      border: 1px solid var(--stroke-gray-medium);
      padding: 4px 8px;

      code, tt {
        padding: .2em .4em;
        margin: 0;
        font-size: 85%;
        white-space: break-spaces;
        background-color: var(--bg-gray-medium);
        border-radius: 6px;
      }

      &:last-child {
        word-break: break-all;
        white-space: pre-wrap;
      }
    }
  }

  p:has(img) {
    width: 100%;
    margin: 0 0 10px 0;

    img {
      width: 100%;
    }
  }

  details {
    padding: 12px 16px;
    overflow: visible;
    color: var(--text-strong);
    background-color: var(--bg-gray-medium);
    border-radius: 12px;
    width: 100%;
    margin: 0 0 10px 0;
    word-wrap: normal;

    &[open] {
      summary {
        margin-bottom: 12px;
      }
    }

    summary {
      cursor: pointer;

      .toolname {
        font-size: 18px;
        display: inline-block;
        font-weight: 700;
        color: var(--text-strong);
      }

      .subTitle {
        color: var(--text-medium);
      }
    }

    table {
      code {
        background: var(--bg-gray-strong);
      }
    }
  }
}

.oap-high-cost-popup {
  .popup-confirm-content {
    padding: 16px 50px;
  }
  .oap-high-cost-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    overflow: hidden;

    .oap-high-cost-title {
      font-size: 18px;
      font-weight: 700;
      color: var(--text-strong);
    }

    .oap-high-cost-desc {
      font-size: 16px;
      color: var(--text-weak);
    }

    .oap-high-cost-list {
      width: 100%;
      display: flex;
      flex-direction: column;
      padding: 0 50px;
      overflow-y: auto;
      @include scrollbar;

      .oap-high-cost-item {
        padding: 20px;

        &:not(:last-child) {
          border-bottom: 1px solid var(--stroke-gray-medium);
        }

        &:first-child {
          padding-top: 10px;
        }

        .oap-high-cost-item-title {
          font-size: 15px;
          font-weight: 600;
        }

        .oap-high-cost-item-list {
          margin: 0;
          margin-top: 5px;
          font-size: 12px;

          li {
            width: fit-content;

            &:hover {
              text-decoration: underline;
            }
          }

          li + li {
            margin-top: 5px;
          }

          .oap-high-cost-item-name {
            @include line-clamp(2);

            .oap-high-cost-item-cost {
              color: var(--text-weak);
            }
          }
        }
      }
    }
  }
}

.unsaved-popup {
  max-width: 400px;

  .unsaved-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 16px;

    .unsaved-header {
      font-weight: 700;
    }

    .unsaved-desc {
      text-align: center;
      color: var(--text-weak);
      padding: 0 50px;
    }
  }
}